﻿/**
 * 
 * Copyright 2009, 2010 Mike Jamer [email: mikejamer@gmail.com ]
 * 
 * This File is part of Moose IRC
 * 
 * MooseIRC is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * MooseIRC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with MooseIRC.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using moose.irc;

namespace mooseirc
{
    /// <summary>
    /// Status Form manages connection to an irc server
    /// </summary>
    public partial class StatusForm : Form
    {

        #region [Local Attributes]

        /// <summary>
        /// Reference to the IRC session
        /// </summary>
        private IrcSession m_session;

        #endregion

        #region [Construction]

        /// <summary>
        /// Initialize Status Form
        /// </summary>
        public StatusForm(IrcSession session)
            : base()
        {
            InitializeComponent(); //Build Form
            m_session = session; //Reference our session

            return;
        }

        #endregion

        #region [Public Methods]

        /// <summary>
        /// Write a message to output
        /// </summary>
        /// <param name="message">message to write</param>
        public void write_output(string message)
        {
            output.write(message);
            return;
        }

        #endregion

        #region [Event Handlers]

        /// <summary>
        /// When user enters something into the input
        /// </summary>
        /// <param name="response"></param>
        private void input_UserResponse(string response)
        {
            if (response[0] == '/')
                m_session.send(response.Substring(1));
            else
                if (m_session.SessionState == IrcSessionStates.Disconnected || m_session.SessionState == IrcSessionStates.None)
                    output.write("***You are not connected to any server.");
                else
                    output.write("***You are not in a channel.");
            return;
        }

        #endregion

    }
}
